#ifdef _GUI
#ifndef _GUI_H_
#define _GUI_H_

#include <threads.h>
#include <gtk/gtk.h>
#include <gtk/gtkbuilder.h>
#include <glib.h>
#include <glib-object.h>
#include <glibconfig.h>
#include <tgmath.h>
#define UI_FILE "./ui.glade"
#define strequ(a, b) (strcmp(a, b) == 0)

int dummy_thrd_func(void *);
int gui_main(int ac, char **av);

extern volatile bool gworking;
extern struct break_collect *break_log;

enum job_type {
        TSEQ, TSEED, WSEQ, WSEED, WRAND
};


struct break_collect {
        int used;
        struct break_log {
            off_t start;
            off_t end;
        } log[1024];
        struct break_collect *next;
};
struct med_name {
        char *name;
        enum job_type job;
        char *tips;
};
struct job_listen{
        char *filepath;
        size_t size;
        size_t from;
        size_t to;
        size_t count;
        uint64_t seed;
        FILE *fp;
        enum job_type job;
};

struct mainui {
        GtkWindow *win;
        GtkButton *runit, *exit, *help;
        GtkEntry *dev;
        GtkEntry *test_seq, *test_seed, *write_seq, *write_seed;
        GtkStackSwitcher *function, *test_method ,*write_method;
};
struct conformui {
        GtkDialog *win;
        GtkCheckButton *chkb_dev, *chkb_size, *chkb_fromto, *chkb_writesize,
            *chkb_method, *chkb_seed, *chkb_final;
        GtkLabel *dev, *size, *fromto, *writesize, *method, *seed;
        GtkButton *exit, *runit;
};
struct progressui {
        GtkWindow *win;
        GtkButton *stop;
        GtkLabel *textstat;
        GtkProgressBar *sub;
};
struct stopui {
        GtkDialog *win;
        GtkCheckButton *yes;
        GtkButton *exit, *ok;
};
struct texterrui {
        GtkDialog *win;
        GtkButton *exit;
        GtkLabel *tips;
};
struct resultui {
        GtkDialog *win;
        GtkTextView *text;
};

struct aboutpage {
        GtkDialog *win;
};

void mainui_show(void);
void mainui_runit(void);
void mainui_help(void);
gboolean mainui_exit(void);
void conformui_show(void);
void conformui_chkb(void);
gboolean conformui_exit(void);
void conformui_runit(void);
void progressui_show(void);
void progressui_stop(void);
void progressui_exit(void);
void stopui_show(void);
void stopui_yes(void);
gboolean stopui_exit(void);
void stopui_ok(void);
void texterrui_show(char *tips);
gboolean texterrui_exit(void);
void resultui_show(void);
gboolean resultui_exit(void);
gboolean aboutpage_exit(void);

#endif // _GUI_H_
#endif // _GUI
